package com.ioidea.holland.greenHouseAct

//如何完善sortPoint() 使数据安装行列从小到大排序
//row 代表行   column 代表列
data class Point(var row:Int,var column:Int)


fun getPoints():ArrayList<Point>{
    val points=ArrayList<Point>()

//    for (i in 0 until 100) {
//        // 在此处执行循环体的代码
//        for (j in 0 until 100) {
//            points.add(Point(i,j))
//        }
//    }
    points.add(Point(1,1))
    points.add(Point(1,2))
    points.add(Point(1,3))
    points.add(Point(1,4))


    points.add(Point(1,5))
    points.add(Point(1,6))
    points.add(Point(1,7))
    points.add(Point(1,8))

    points.add(Point(2,1))
    points.add(Point(2,2))
    points.add(Point(2,3))

    points.add(Point(2,4))

    return points
}

fun sortPoint():List<Point>{
    val points = getPoints()
    val sortedPoints = points.sortedWith(compareBy({ it.row }, { it.column }))

    sortedPoints.forEach { println("Row: ${it.row}, Column: ${it.column}") }
return sortedPoints
}

fun main() {
    sortPoint()
}